﻿@{
    Layout = null;
}

<form id="form_AllotCodeAdd" role="form" class="form-horizontal" onkeydown="if(event.keyCode==13){return false;}">
    <input type="hidden" id="ID" />
    <div id="VerifieView">
        <div class="form-group">

            <div class="col-xs-2 col-md-2 text-right">
                申请机构
            </div>
            <div class="col-xs-4 col-md-4">
                <input id="T_Entperise" type="text" disabled="disabled" name="name" value="" class="form-control" />
                <input type="hidden" id="T_EntperiseId" />
            </div>

            <div class="col-xs-2 col-md-2 text-right">
                申请人
            </div>
            <div class="col-xs-4 col-md-4">
                <input id="ApplyUserName" type="text" disabled="disabled" name="name" value="" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-2 col-md-2 text-right">
                申请数量(单标)
            </div>
            <div class="col-xs-4 col-md-4">
                <input id="ApplyCount" type="text" disabled="disabled" name="name" value="" class="form-control" />
            </div>

            <div class="col-xs-2 col-md-2 text-right">
                申请码类型:
            </div>
            <div class="col-xs-4 col-md-4 text-left">
                <input class="CodeType" type="checkbox" name="name" value="1" disabled="disabled" />
                <label for="">服务码</label>
                <input class="CodeType" type="checkbox" name="name" value="2" disabled="disabled" />
                <label for="">管理码</label>
                <input type="hidden" name="CodeFunc" id="CodeFunc" />
            </div>

        </div>
        <div class="form-group">
            <div class="col-xs-2 col-md-2 text-right">
                应用产品
            </div>
            <div class="col-xs-4 col-md-4">
                <input id="ProductName" type="text" disabled="disabled" name="name" value="" class="form-control" />
            </div>

            <div class="col-xs-2 col-md-2 text-right">
                产品规格
            </div>
            <div class="col-xs-4 col-md-4">
                <input id="ProductSize" type="text" disabled="disabled" name="name" value="" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-2 col-md-2 text-right">
                申请理由
            </div>
            <div class="col-xs-10 col-md-10">
                <textarea id="ApplyReason" disabled="disabled" class="form-control"></textarea>
            </div>
        </div>
    </div>
    <div id="TestContent" style="display:none;">
        <div class="form-group">
            <div class="col-xs-2 col-md-2 text-right" style="padding-right:22px;">
                审核结果
            </div>
            <div class="col-xs-2 col-md-2 text-left" style="margin:0;padding-left:8px;">
                <button type="button" id="Pass" onclick="$.MGJ.AllotCode.Pass()" class="btn btn-default">通过</button>
            </div>
            <div class="col-xs-2 col-md-2 text-left" style="margin:0;">
                <button type="button" id="NotPass" onclick="$.MGJ.AllotCode.NotPass()" class="btn btn-default active">不通过</button>
            </div>
        </div>
        <div class="form-group" id="NotPassContent">
            <div class="col-xs-2 col-md-2 text-right">
                不通过原因
            </div>
            <div class="col-xs-10 col-md-10">
                <textarea id="VerificationNotes" class="form-control"></textarea>
            </div>
        </div>
        <div class="form-group" style="display:none" id="PassContent">
            <div class="form-group">
                <div class="col-xs-2 col-md-2 text-right">
                    申请数量(单标)
                </div>
                <div class="col-xs-10 col-md-10">
                    <input id="ApplyCount2" disabled="disabled" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <div class="col-xs-2 col-md-2 text-right">
                    分配方式
                </div>
                <div class="col-xs-2 col-md-2 text-left" style="margin:0;">
                    <button type="button" id="ByCodeNum" onclick="$.MGJ.AllotCode.ByCodeNum($.MGJ.AllotCode.SetAllotType(0))" class="btn btn-default active">号段</button>
                </div>
                <div class="col-xs-2 col-md-2 text-left" style="margin:0;">
                    <button type="button" id="ByFullPage" onclick="$.MGJ.AllotCode.ByFullPage($.MGJ.AllotCode.SetAllotType(1))" class="btn btn-default ">整批</button>
                </div>
            </div>
            <div class="form-group">
                <div class="col-xs-2 col-md-2 text-right">
                    <span class="red-700">*</span>
                    生码批次
                </div>
                <div class="col-xs-10 col-md-10">
                    <select class="form-control" name="GenCodeBatch" onchange="$.MGJ.AllotCode.onBatchChange()" id="GenCodeBatch"></select>
                </div>
                <input type="hidden" id="HidCount" value="0" />
            </div>

            <div id="NeedStatEndCode">
                <div class="form-group">
                    <div class="col-xs-2 col-md-2 text-right">
                        <span class="red-700">*</span>
                        起始码
                    </div>
                    <div class="col-xs-4 col-md-4">
                        <input type="text" id="StartCode" name="StartCode" onchange="CodeAmount()" class=" form-control" oninput="scanf_integral (event)" />
                    </div>

                    <div class="col-xs-2 col-md-2 text-right">
                        <span class="red-700">*</span>
                        结束码
                    </div>
                    <div class="col-xs-4 col-md-4">
                        <input type="text" id="EndCode" onchange="CodeAmount()" name="EndCode" class="form-control" oninput="scanf_integral (event)" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-xs-2 col-md-2 text-right">
                        已选数量(单标)
                    </div>
                    <div class="col-xs-10 col-md-10">
                        <input id="AllotCount" class="form-control" name="AllotCount" readonly="readonly">
                    </div>
                </div>
            </div>
            <div id="NeedStatEndCode2" style="display:none;">
                <div class="form-group">
                    <div class="col-xs-2 col-md-2 text-right">
                        已选数量(单标)
                    </div>
                    <div class="col-xs-10 col-md-10">
                        <input id="AllotCount2" class="form-control" name="AllotCount2" readonly="readonly">
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<div class="modal-footer" style="margin-bottom:-20px;">
    <button id="PrevStep" style="display:none;" class="btn btn-primary" onclick="$.MGJ.AllotCode.PrevStep()">上一步</button>
    <button id="NextStep" class="btn btn-primary" onclick="$.MGJ.AllotCode.NextStep()">下一步</button>
    @*<button id="NextStep" class="btn btn-primary" onclick="$.MGJ.Common.loadurl(this, '/CodeManage/RawCode', '0', '0', '0'); $.MGJ.AllotCode.CloseDialog()">下一步</button>*@
    <button class="btn btn-default" onclick="$.MGJ.AllotCode.CloseDialog()">取消</button>
</div>

<script>
    $("#NextStep").click(function () {
        $("#admui-navTabsItem-1 .site-menu>li:eq(2)>ul>li:eq(0)").addClass("site-menu-active")
        $("#admui-navTabsItem-1 .site-menu>li:eq(2)>ul>li:eq(7)").removeClass("site-menu-active")
    })

    function CodeAmount() {
        var StartCode = $("#StartCode").val()
        var EndCode = $("#EndCode").val()
        if (StartCode != "" && EndCode != "") {
            $("#AllotCount").val(parseInt(EndCode) - parseInt(StartCode) + 1);
        }
    }


    //起始码结束码
    function scanf_integral() {
        var StartCode = $("#StartCode").val();
        var EndCode = $("#EndCode").val();
        if (StartCode != '' && EndCode != '') {
            $("#AllotCount").val(parseInt(EndCode) - parseInt(StartCode) + 1);
        }
    }
    $("#StartCode,#EndCode").blur(function () {
        var start = $("#StartCode").val()
        var end = $("#EndCode").val()
        if (start != '' && end != '') {
            var num = end - start
            if (num < 0) {
                //alert('结束码必须大于起始码!');
            }
        }
    })





    $(".modal-footer")[1].remove();
    if (DataModel) {
        
        $("#ID").val(DataModel.ID);
        $("#CodeFunc").val(DataModel.CodeFunc);
        $("#T_EntperiseId").val(DataModel.T_EnterpriseId);
        $("#T_Entperise").val(DataModel.T_EnterpriseName);
        $("#ApplyUserName").val(DataModel.ApplyUserName);
        
        //$("#AllotCount").val(DataModel.AllotCount);
        //$("#AllotCount2").val(DataModel.AllotCount);
        $("#BrandName").val(DataModel.BrandName);
        $("#ProductName").val(DataModel.AllotProductName);
        $("#ProductSize").val(DataModel.ApplyProductSize);
        $("#ApplyReason").val(DataModel.ApplyReason);
        $("#ApplyCount").val(DataModel.ApplyCount);
        $("#ApplyCount2").val(DataModel.ApplyCount);
    }


    $(function () {
        $('#form_AllotCodeAdd').bootstrapValidator({
            fields: {
                GenCodeBatch: {
                    validators: {
                        notEmpty: {
                            message: '生码批次不能为空'
                        }
                    }
                },
                StartCode: {
                    validators: {
                        regexp: {
                            regexp: /^[1-9]*[1-9][0-9]*$/,
                            message: '起始码为正整数'
                        },
                        notEmpty: {
                            message: '起始码不能为空'
                        }
                    }
                },
                EndCode: {
                    validators: {
                        regexp: {
                            regexp: /^[1-9]*[1-9][0-9]*$/,
                            message: '结束码为正整数'
                        },
                        notEmpty: {
                            message: '结束码不能为空'
                        }
                    }
                }



            }
        })
    })
</script>
